nova-compute-pkg:
  pkg.installed:
    - names:
      - openstack-nova-compute
      - sysfsutils

nova-compute-nova-conf:
  file.managed:
    - name: /etc/nova/nova.conf
    - source: salt://openstack/queen/nova-compute/files/nova.conf
    - user: root
    - group: nova
    - mode: 640
    - template: jinja
    - defaults:
      IP_ADDR: {{ grains['fqdn_ip4'][0] }}
      RABBITMQ_OPENSTACK_USER: {{ pillar['rabbitmq']['RABBITMQ_OPENSTACK_USER'] }}
      RABBITMQ_OPENSTACK_PASS: {{ pillar['rabbitmq']['RABBITMQ_OPENSTACK_PASS'] }}
      RABBITMQ_IP: {{ pillar['rabbitmq']['RABBITMQ_IP'] }}
      MEMCACHED_IP: {{ pillar['memcached']['MEMCACHED_IP'] }}
      GLANCE_IP: {{ pillar['glance']['GLANCE_IP'] }}
      KEYSTONE_IP: {{ pillar['keystone']['KEYSTONE_IP'] }}
      NOVA_KEYSTONE_USER: {{ pillar['nova']['NOVA_KEYSTONE_USER'] }}
      NOVA_KEYSTONE_PASS: {{ pillar['nova']['NOVA_KEYSTONE_PASS'] }}
      NOVA_VNC_IP: {{ pillar['nova']['NOVA_VNC_IP'] }}
      VIRT_TYPE: {{ pillar['nova']['VIRT_TYPE'] }}
      PLACEMENT_KEYSTONE_USER: {{ pillar['placement']['PLACEMENT_KEYSTONE_USER'] }}
      PLACEMENT_KEYSTONE_PASS: {{ pillar['placement']['PLACEMENT_KEYSTONE_PASS'] }}
      NEUTRON_KEYSTONE_USER: {{ pillar['neutron']['NEUTRON_KEYSTONE_USER'] }}
      NEUTRON_KEYSTONE_PASS: {{ pillar['neutron']['NEUTRON_KEYSTONE_PASS'] }}
      NEUTRON_IP: {{ pillar['neutron']['NEUTRON_IP'] }}
    - require:
      - pkg: nova-compute-pkg

nova-libvirtd-service:
  service.running:
    - name: libvirtd
    - enable: True
    - require:
      - pkg: nova-compute-pkg

nova-compute-service:
  service.running:
    - name: openstack-nova-compute
    - enable: True
    - require:
      - pkg: nova-compute-pkg
    - watch:
      - file: nova-compute-nova-conf
